package com.uxwine.view.t;

import com.uxwine.alarm.R;
import com.uxwine.view.t.MarkerLayer.MarkerEventListener;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.MeasureSpec;
import android.widget.FrameLayout;
import android.widget.ImageView;

public class TimeSpanMarker extends View {

	Drawable mMarker;
	private Point mPosition;
	private float mfRate;

	private static final String TAG = MarkerLayer.class.getName();
	
	public TimeSpanMarker(Context context, AttributeSet attrs) {
		super(context, attrs);		
		initView(context);
	}
	
	public void moveTo(int x, int y)
	{
		mPosition.x = x;
		mPosition.y = y;
	}
	
	public void setRate(float rate)
	{
		mfRate = rate;
	}
	
	public int getMarkerWidth()
	{
		return getMarkerHeight() * 1;
	}
	

	public int getMarkerHeight()
	{
		return (int)(getMeasuredHeight() * mfRate);
	}

	@Override
	protected void onDraw(Canvas canvas) {		
		
		int h = (int)(getMeasuredHeight() * mfRate);//r.right - r.left;
		int w = h; //(int)(getMeasuredHeight() * mfRate);//r.bottom - r.top;
		
		int x = mPosition.x;
		int y = mPosition.y;
		
		mMarker.setBounds(x, y, x + w, y + h);		
		mMarker.draw(canvas);
	}
	
	void initView(Context context) {
		Resources res = getResources();
		mMarker  = (Drawable)res.getDrawable(R.drawable.time_maker);
		mPosition = new Point(0, 0);
	}	
}
